<?php


namespace services\linkedcare;

use common\components\Service;
use common\models\linkedcare\LinkedcarePatientsOrderDetail;
use Yii;

class LinkedcarePatientsOrderDetailService extends Service
{
    /**
     * 获取消费治疗项目明细
     * @param array $chargeOrderIds
     * @return array
     */
    public static function getFeeListMap(array $chargeOrderIds): array
    {
        $data = LinkedcarePatientsOrderDetail::find()
            ->where([
                'chargeOrderId' => $chargeOrderIds,
            ])
            ->orderBy([
                'confirmTime' => SORT_DESC,
                'id' => SORT_DESC,
            ])
            ->asArray()
            ->all();
        $dataFormat = [];
        foreach ($data as $row) {
            $dataFormat[$row['chargeOrderId']] = $dataFormat[$row['chargeOrderId']] ?? [];
            $dataFormat[$row['chargeOrderId']][] = $row;
        }
        return $dataFormat;
    }
}
